]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st: Add st_icon_colors_equal()
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 2 May 2019 18:27:05 +0000 (20:27 +0200)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Sun, 7 Jul 2019 21:01:33 +0000 (21:01 +0000)
This is a small convenience wrapper around clutter_color_equal()
for the different color components, which also handles the case
where one (or both) of the icon colors are %NULL.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1212

src/st/st-icon-colors.c
src/st/st-icon-colors.h

index 21bec6ee306d26e3183319fc758b2f74f24c9369..8c5b8d35ab912a0b8166db78e78d3edbd0d0e9db 100644 (file)
@@ -102,6 +102,29 @@ st_icon_colors_copy (StIconColors *colors)
   return copy;
 }
 
+/**
+ * st_icon_colors_equal:
+ * @colors: a #StIconColors
+ * @other: another #StIconColors
+ *
+ * Returns: %TRUE if the #StIconColors are equal
+ */
+gboolean
+st_icon_colors_equal (StIconColors *colors,
+                      StIconColors *other)
+{
+  if (colors == other)
+    return TRUE;
+
+  if (colors == NULL || other == NULL)
+    return FALSE;
+
+  return clutter_color_equal (&colors->foreground, &other->foreground) &&
+         clutter_color_equal (&colors->warning, &other->warning) &&
+         clutter_color_equal (&colors->error, &other->error) &&
+         clutter_color_equal (&colors->success, &other->success);
+}
+
 G_DEFINE_BOXED_TYPE (StIconColors,
                      st_icon_colors,
                      st_icon_colors_ref,
index b582308a54cff5a44b661086f50e65b482ee8433..e994a7522ac4fa9ffd3328ed0a935978fec5fccc 100644 (file)
@@ -35,6 +35,8 @@ StIconColors *st_icon_colors_new   (void);
 StIconColors *st_icon_colors_ref   (StIconColors *colors);
 void          st_icon_colors_unref (StIconColors *colors);
 StIconColors *st_icon_colors_copy  (StIconColors *colors);
+gboolean      st_icon_colors_equal (StIconColors *colors,
+                                    StIconColors *other);
 
 G_END_DECLS